<?php
	$q = mysql_query("SELECT `user_id` FROM `opt_out` WHERE `student_id`=".$user_id." LIMIT 1");
	$q_result = mysql_result($q,0);
	if (!empty($_POST['submitting'])) {
		if (is_numeric($q_result)) {
			$optout=true;
			# currently opting out
			if (empty($_POST['optout'])) {
				# user is opting BACK IN
				$optout=false; $updating=true;
				mysql_query("DELETE FROM `opt_out` WHERE `user_id`=".$user_id." LIMIT 1");
			}
		} else {
			# currently opted in
			if (!empty($_POST['optout'])) {
				# user is opting OUT
				mysql_query("INSERT INTO `opt_out` (`user_id`) VALUES (".$user_id.")");
				$optout=true; $updating=true;
			}
		}
	} else if (is_numeric($q_result)) { $optout=true; }
?>
<div id="ou-region0">
	<ol class="ou-ancestors" id="rise-breadcrumb">
		<li><a href="http://library.open.ac.uk">OU Library Services</a></li>
<?php if (strpos($_SERVER['HTTP_REFERER'],"rise")) { echo "     <li><a href=\"http://library.open.ac.uk/rise\">MyRecommendations</a></li>\n"; } ?>
		<li><a href="/">Privacy Policy</a></li>
		<li id="results-breadcrumb" style="display:none;"></li>
	</ol>
	<?php echo ($updating?"<div class=\"notify-success\">Thank You - Your ".($optout?"details will be removed from the recommendations system within 24 hours":"preferences have been updated").".</div>\n":""); ?>
	<h1 style="font-size:25px;padding-bottom:4px;margin-bottom:-6px;">Privacy Policy</h1>
	<p>The Open University General Privacy Policy can be found <a href="http://www.open.ac.uk/privacy/">here</a>.</p>
	
	<h3 style="text-decoration:underline">Privacy Policy relating to the use of library search systems</h3>
	<p>When you search for and/or access bibliographic resources such as journal articles, your request will be recorded in a system which captures activity data.
	Anonymised search patterns may be included in an aggregation of data about the use of resources in order to provide a recommendations service.
	This anonymised aggregation may be shared with third parties but contains no information that could identify you as an individual.</p>
	
	<p>To improve the quality of our recommendations, we would like to use your search information in this way but offer you an opportunity to opt out of the system.
	If you opt out of the system, please be aware that the recommendations system will not show records of your activity although the log files of the search systems will still retain a history of your searches for security purposes.</p>
	<form method="post" action="">
	<?php
		if ($optout) { $checked = " checked=\"checked\""; }
		echo "<input type=\"checkbox\" name=\"optout\" id=\"optout\" style=\"width:50px; height:50px;margin: auto auto;float:left;display:block;\" $checked/>\n";
	?>
		<div>
			<p>I do not want my search information to be included in the recommendations system.<br/>
			<span style="font-size:11px;color:#555555;">Please note this will only affect data relating to the OUCU with which you're currently logged in.
			If you have other OUCUs for which you wish to remove data, please log-in and complete this process for each.</span>
		</div>

    <?php if ($optout) { echo "<p>You are currently opted out of the recommendations system, to opt back in, please un-tick the box above, and click &quot;Submit Preferences&quot;.</p>\n"; } ?>
		<div style="text-align:center;">
			<input type="submit" value="Submit Preferences" id="submitoptout" style="height:25px;width:200px;"/>
			<input type="hidden" name="submitting" value="true"/>
		</div>
	</form>
</div>
<div id="ou-region1">
</div>
<div id="ou-region2">
</div>